package com.thssh.ui.utils;

import com.thssh.ui.App;

/**
 * @author zhangyugehu
 * @version V1.0
 * @date 2017/09/08
 * email: zhangyugehu@163.com
 */

public class UiUtils {

    public static int dp2px(int dp){
        try {
            final float scale = App.getInstance().getApplicationContext().getResources().getDisplayMetrics().density;
            return (int) (dp * scale + 0.5f);
        }catch (Exception e){

        }
        return dp;
    }

    public static int px2dp(int px){
        try {
            final float scale = App.getInstance().getApplicationContext().getResources().getDisplayMetrics().density;
            return (int) (px / scale + 0.5f);
        }catch (Exception e){

        }
        return px;
    }
}
